package com.K_lificapp;

import java.util.List;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;


public class MainActivity extends ListActivity {
	
	private CursosDataSource datasource;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		datasource = new CursosDataSource(this);
	    datasource.open();

	    List<Cursos> values = datasource.getAllCursos();

	    ArrayAdapter<Cursos> adapter = new ArrayAdapter<Cursos>(this,
	        android.R.layout.simple_list_item_1, values);
	    setListAdapter(adapter);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	public void onClick(View view) {
//		setContentView(R.layout.agregarcursos_layout);
		Intent i = new Intent(MainActivity.this, CursosActivity.class);
		startActivity(i);
	}

}
